<html>
	<title> User List </title>
	<body>
	<form action="search_users.php" method="GET">
		<input type="text" placeholder="search by username" name="username">
		<input type="submit" name="submit" value="Search">	
	</form>
	
	<table border="5">
			<tr>
				<th> First Name </th>
				<th> Last Name </th>
				<th> Username </th>
				<th> Usertype </th>
				<th> Date Created </th>
			</tr>
			<?php
				include("users.php");
				$obj = new users();
				
				if(!$obj-> get_all_users()){
					echo ("Error").mysql_error($obj->link);
					exit();
				}
				
				$row=$obj->fetch();
				
				while($row){
					$userId=$row['userId'];
					echo "<tr><td>".$row['firstname']. "</td>";
					echo "<td>".$row['lastname']."</td>";
					echo "<td>".$row['username']."</td>";
					echo "<td>".$row['usertype']."</td>";
					echo "<td>".$row['datecreated']."</td>";
					echo "<td><a target='_blank' href='user_edit.php?userId=$userId'> EDIT </a></td></tr>";
					$row=$obj->fetch();
				}
				

			?>
			</table>
		To add a user <a target="_blank" href="add_user.php"> Click here </a> 
	</body>
</html>